<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 15, 2009 at 1:25:33 pm</time-stamp>


<class>
<name>Item</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>name buyPrice sellPrice sku quantity reorderPoint dateRecieved </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.Item class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="named:sku:">named: anItemName sku: aCode
	"Creates a new Item object instance. This constructor should set appropriate values (name and sku) of the instance."
	
	| newItem |
	newItem := Item new.
	newItem name: anItemName.
	newItem sku: aCode.
	newItem quantity: 0.
	^newItem.</body>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.Item</class-id>
<body>Item represents a single item of inventory in a supply chain, as purchased by a supplier, to be sold to a buy.

Instance Variables:
	buyPrice	&lt;Double&gt;	The price paid for the item by the supplier
	name	&lt;String&gt;	The name of the item
	quantity	&lt;SmallInteger&gt;	The number of item in stock
	reorderPoint	 &lt;SmallInteger&gt;	The quantity that signals the need to reorder
	sellPrice	&lt;Double&gt;	 The price a buyer pays for the item
	sku	&lt;String&gt;	The sku of a particular item

</body>
</comment>

<methods>
<class-id>SupplyChain.Item</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	name := nil.
	buyPrice := 0.0.
	sellPrice := 0.0.
	sku := nil.
	quantity := 0.
	reorderPoint := 0.
	dateRecieved := Date today.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Item</class-id> <category>accessing</category>

<body package="SupplyChain" selector="buyPrice">buyPrice
	^buyPrice</body>

<body package="SupplyChain" selector="buyPrice:">buyPrice: anObject
	buyPrice := anObject</body>

<body package="SupplyChain" selector="dateRecieved">dateRecieved
	^dateRecieved</body>

<body package="SupplyChain" selector="dateRecieved:">dateRecieved: anObject
	dateRecieved := anObject</body>

<body package="SupplyChain" selector="lotNumber">lotNumber
	^lotNumber.</body>

<body package="SupplyChain" selector="lotNumber:">lotNumber: aNumber
	lotNumber:= aNumber.</body>

<body package="SupplyChain" selector="name">name
	^name</body>

<body package="SupplyChain" selector="name:">name: anObject
	name := anObject</body>

<body package="SupplyChain" selector="quantity">quantity
	^quantity</body>

<body package="SupplyChain" selector="quantity:">quantity: anObject
	quantity := anObject</body>

<body package="SupplyChain" selector="reorderPoint">reorderPoint
	^reorderPoint</body>

<body package="SupplyChain" selector="reorderPoint:">reorderPoint: anObject
	reorderPoint := anObject</body>

<body package="SupplyChain" selector="sellPrice">sellPrice
	^sellPrice</body>

<body package="SupplyChain" selector="sellPrice:">sellPrice: anObject
	sellPrice := anObject</body>

<body package="SupplyChain" selector="sku">sku
	^sku</body>

<body package="SupplyChain" selector="sku:">sku: anObject
	sku := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.Item</class-id> <category>changing</category>

<body package="SupplyChain" selector="restockItem:">restockItem: anItem
	"Adds to the local inventory"

	quantity := quantity + anItem quantity</body>
</methods>

<methods>
<class-id>SupplyChain.Item</class-id> <category>required</category>

<body package="SupplyChain" selector="itemValue">itemValue
	"Returns the value of this item computed as quantity * buy Price"
	^((self quantity) * (self buyPrice)).</body>

<body package="SupplyChain" selector="needsReorder">needsReorder
	"Returns true if the quantity is less than reorderPoint, false otherwise"

	^((self quantity) &lt; (self reorderPoint)).</body>

<body package="SupplyChain" selector="potentialProfit">potentialProfit
	"Returns the profit multiplied by the quantity"
	
	^(((self quantity) * (self sellPrice)) - ((self quantity) * (self buyPrice))).</body>

<body package="SupplyChain" selector="printString">printString
	"Returns a string rep of the item in format ''quantity name sku "
	^(((self quantity) printString),' ',(self name),' ',(self sku)).</body>

<body package="SupplyChain" selector="profit">profit
	"Returns the difference between the sell and buy price."
	
	^((self sellPrice) - (self buyPrice)).</body>
</methods>

</st-source>
